//
//  htvsampleone.m
//  PHApp
//
//  Created by zhangwq on 16/4/11.
//  Copyright © 2016年 HT. All rights reserved.
//

#import "htvsampleone.h"
#import "HTFrameKit.h"
#import "HTSysKit.h"
#import "HTFrameConvert.h"
#import "UIImageView+WebCache.h"

@interface htvsampleone (){
    CGFloat width;
    CGFloat height;
}

@property (nonatomic, strong) NSOperationQueue *queue;

@end

@implementation htvsampleone

- (NSOperationQueue *)queue {
    if (!_queue) _queue = [[NSOperationQueue alloc] init];
    return _queue;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize size = rect.size;
    width = size.width;
    height = size.height;
    
    UIColor *backcolor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0];
    
    
    UIImageView *iv=[[UIImageView alloc]initWithFrame:CGRectMake(20,80, width-40,150)];
    iv.accessibilityLabel=@"http://7xshdz.com2.z0.glb.clouddn.com/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202016-04-11%2011.50.21.png";
    [iv setClipsToBounds:YES];
    [iv setContentMode:UIViewContentModeScaleAspectFit];
    iv.layer.masksToBounds=YES;
    iv.layer.cornerRadius = 4;
    iv.userInteractionEnabled=YES;
    [self downloadImg:iv];
    [self.view addSubview:iv];
    
    
    UILabel *lbzh=[[UILabel alloc]initWithFrame:CGRectMake(20, 240, width, 20)];
    lbzh.text=[[NSString alloc]initWithFormat:@"展会：%@",@"2016上海面料夏季展"];
    lbzh.textColor=backcolor;
    lbzh.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbzh];
    
    
    UILabel *lbno=[[UILabel alloc]initWithFrame:CGRectMake(20, 260, width, 20)];
    lbno.text=[[NSString alloc]initWithFormat:@"单号：%@",@"1609821"];
    lbno.textColor=backcolor;
    lbno.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbno];
    
    UILabel *lbdate=[[UILabel alloc]initWithFrame:CGRectMake(20, 280, width, 20)];
    lbdate.text=[[NSString alloc]initWithFormat:@"日期：%@",@"2016年3月23日14:23"];
    lbdate.textColor=backcolor;
    lbdate.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbdate];
    
    UILabel *lbsale=[[UILabel alloc]initWithFrame:CGRectMake(20, 300, width, 20)];
    lbsale.text=[[NSString alloc]initWithFormat:@"业务：%@",@"魏然"];
    lbsale.textColor=backcolor;
    lbsale.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbsale];
    
    UILabel *lbvendor=[[UILabel alloc]initWithFrame:CGRectMake(20, 320, width, 20)];
    lbvendor.text=[[NSString alloc]initWithFormat:@"客户：%@",@"上海技嘉"];
    lbvendor.textColor=backcolor;
    lbvendor.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbvendor];
    
    UILabel *lbop=[[UILabel alloc]initWithFrame:CGRectMake(20, 340, width, 20)];
    lbop.text=[[NSString alloc]initWithFormat:@"联系：%@",@"王总"];
    lbop.textColor=backcolor;
    lbop.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbop];
    
    UILabel *lbtel=[[UILabel alloc]initWithFrame:CGRectMake(20, 360, width, 20)];
    lbtel.text=[[NSString alloc]initWithFormat:@"电话：%@",@"+86 1387265152"];
    lbtel.textColor=backcolor;
    lbtel.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbtel];
    
    
    UILabel *lbqty=[[UILabel alloc]initWithFrame:CGRectMake(20, 380, width, 20)];
    lbqty.text=[[NSString alloc]initWithFormat:@"数量：%@",@"56"];
    lbqty.textColor=backcolor;
    lbqty.font=[UIFont fontWithName:@"Arial" size:12.0];
    [self.view addSubview:lbqty];
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (void)downloadImg:(UIImageView *)theImageView {
    
    NSString *imageName=[[NSString alloc]initWithFormat:@"%@?imageView2/2/w/400",theImageView.accessibilityLabel];
    NSURL *imagePath = [NSURL URLWithString:imageName];
    [self.queue addOperationWithBlock: ^{
        
        //在主线程中更新UI
        [[NSOperationQueue mainQueue] addOperationWithBlock: ^{
            [theImageView sd_setImageWithURL:imagePath placeholderImage:[UIImage imageNamed:@"nop"]];
        }];
    }];
}








- (IBAction)backAction:(UIButton *)sender {
    [self dismissViewControllerAnimated: YES completion: nil ];
}
@end
